{extend name="base/base" /}
{block name="content"}
        <form class="layui-form" id="edit_form" onsubmit="return false">
        <input type="hidden" name="id" value="{$data.id ?? ''}">
            <div class="layui-form-item">
              <label class="layui-form-label">开关</label>
              <div class="layui-input-block">
                  <input type="checkbox" name="is_open" lay-skin="switch" {$data.is_open == 1 ? 'checked' : ''}>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">赠送币种</label>
              <div class="layui-input-inline">
              <select class="layui-input" name='cid'>
                {foreach $coin as $val}
                  {if $val.id == $data.cid}<option value="{$val.id}" selected="selected">{$val.name}</option>
                  {else /}<option value="{$val.id}">{$val.name}</option>
                  {/if}
                {/foreach}
              </select>
            </div>
            </div>
            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">赠送数量</label>
              <div class="layui-input-inline">
                 <input type="text" name="amount"  placeholder="请输入赠送数量" autocomplete="off" class="layui-input" value="{$data.amount}">
              </div>
            </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-filter="formDemo" onclick="ajax()">立即提交</button>
              <!-- <button onclick="cancel()" class="layui-btn layui-btn-primary">取消</button> -->
            </div>
          </div>
        </form>
{/block}
{block name="script"}
<script>
function ajax(){
  var post_data = $("#edit_form").serialize();
  $.ajax({
      url:"",
      type:"POST",
      data:post_data,
      success:function(ret){
          if (ret.code == 0) {
              layer.msg('操作成功');
              window.location.reload();
          }
          if (ret.code == 1) {
              layer.msg(ret.msg);
          }
      }
  });
}
function cancel(){
    layer.close(layer.index);
    // window.location.href=document.referrer;
}
</script>
{/block}
